Skip to main content

Advanced Storage

Updated Mar 27, 2021 ·

Tasks

Note: You will need an additional 10GiB additional ahrddisk on your virtual machine. This will be divided into three parts

Part 1

  1. Create an LVM with the name lvdb with a size of 1GiB.
  2. Create the VG and PV.
  3. Format the LV with xfs file system.
  4. Mount it on /mounts/lvdb.

Part 2

  1. Create a 10TiB thin provisioning volume.

Part 3

  1. Create a 1GiB LUKX encrypted volume with the name secret.
  2. Mount it persistently but not automatically on /mounts/secret.

Solution

Part 1

Create a physical volume (PV) on the disk (/dev/sdb in this example):

sudo pvcreate /dev/sdb

Create a volume group (VG) named vgdb:

sudo vgcreate vgdb /dev/sdb

Create a logical volume (LV) named lvdb with a size of 1GiB:

sudo lvcreate -L 1G -n lvdb vgdb

Format the logical volume with xfs file system:

sudo mkfs.xfs /dev/vgdb/lvdb

Create a mount point and mount the LV persistently:

sudo mkdir -p /mounts/lvdb
sudo nano /etc/fstab

Add the following line to /etc/fstab to mount the LV persistently:

/dev/vgdb/lvdb /mounts/lvdb xfs defaults 0 0

Save and exit the editor (Ctrl+X, then Y and Enter). Mount the LV:

sudo mount -a

Part 2

Create a logical volume (LV) with thin provisioning:

sudo lvcreate -L 10T -V 10T --thinpool vgdb/thinpool

This creates a thin provisioning logical volume of 10TiB size named thinpool in the vgdb volume group.

Part 3

Create a LUKS encrypted volume. Follow the prompts to set a passphrase for encryption.

sudo cryptsetup luksFormat /dev/sdb1

Open the encrypted volume:

sudo cryptsetup luksOpen /dev/sdb1 secret

Format the encrypted volume with a file system (e.g., ext4):

sudo mkfs.ext4 /dev/mapper/secret

Create a mount point and mount the encrypted volume persistently but not automatically:

sudo mkdir -p /mounts/secret
sudo nano /etc/crypttab

Add the following line to /etc/crypttab to configure the encrypted volume:

secret /dev/sdb1 none luks

Save and exit the editor (Ctrl+X, then Y and Enter). Edit /etc/fstab to add the mount point:

sudo nano /etc/fstab

Add the following line to /etc/fstab to mount the encrypted volume persistently:

/dev/mapper/secret /mounts/secret ext4 defaults 0 0

Save and exit the editor (Ctrl+X, then Y and Enter).